package com.guigu.tankai.controller;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.guigu.aop.OpLog;
import com.guigu.tankai.pojo.Dmoduledetails;
import com.guigu.tankai.service.DmoduledetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("Dmoduledetails.do")
public class DmoduledetailsController {

    @Autowired
    DmoduledetailsService dmoduledetails;
    //删除在添加产品物料组成明细
    @RequestMapping("/DelAdd")

    @OpLog(opModule = "物料组成设计",operType = "删除/添加产品",operDesc = "此方法用于删除/添加产品")
    public String DelAdd(String lists){
        List<Dmoduledetails> list = new Gson().fromJson(lists,new TypeToken<List<Dmoduledetails>>(){}.getType());
        System.out.println(list);
        dmoduledetails.Del(list.get(0).getParentid());
        for (Dmoduledetails ds : list) {
            dmoduledetails.add(ds);
        }
        return "/tan_kai/Dmgg.html";
    }
//根据id查老爹
    @RequestMapping("/listxb")
    @ResponseBody
    public List<Dmoduledetails> listxb(String ParentId){
        return dmoduledetails.selectBy(ParentId);
    }


    @RequestMapping("/ChaWuLiao")
    @ResponseBody
    public List<Dmoduledetails> ChaWuLiao(String productid){
        List<Dmoduledetails> dmoduledetailss = dmoduledetails.ChaWuLiao(productid);
        return dmoduledetailss;
    }


}
